<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"/>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="misapplication-tap-highlight" content="no"/>
		<meta name="HandheldFriendly" content="true"/>
		<meta name="MobileOptimized" content="320"/>
		<title>课程详情</title>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/index.js"></script>
		<script type="text/javascript" src="js/update.js"></script>
		<script type="text/javascript" src="../../js/jquery-1.9.1.min.js"></script>
		<script type="text/javascript" charset="utf-8">
		//加载子页面
		mui.plusReady(function(){
			var self = plus.webview.currentWebview();
      		var type= self.type;
      		var title= self.title;
      		var user_id = plus.storage.getItem('user_id');
            mui.init({
                subpages:[{
                    url:'courseChild/courseDetailChild.html',//子页面HTML地址，支持本地地址和网络地址
                    id:'courseDetailChild',//子页面标志
                    styles:{
                        top:'44px',//子页面顶部位置
                        bottom:'0'//子页面底部位置
                        
                    },
                    extras:{
                        	type:type,title:title
                        }
                }]
            });
            //判断是否收藏
            mui.ajax({ //ajax请求
				url: getServerIp + 'AppCourse/sfCollection',
				type: 'GET',
				data: {
					course_id: type,user_id:user_id
				}, //传参
				success: function(data, textStatus, jqXHR) {
					if(data.code == "2"){
						$('#icon-star').removeClass("mui-icon-star").addClass("mui-icon-star-filled");//样式
					}else{
						$('#icon-star').removeClass("mui-icon-star-filled").addClass("mui-icon-star");//样式
					}
					
				}
			});
            //收藏
            document.getElementById('icon-star').addEventListener('tap', function() {
            	var userinfo = plus.storage.getItem('userinfo');
            	if (userinfo != '' && userinfo != null) {
	            	if ($(this).hasClass("mui-icon-star")) {
	            		//$(this).removeClass("mui-icon-star").addClass("mui-icon-star-filled");//样式
	            		mui.ajax({ //ajax请求
							url: getServerIp + 'AppCourse/addCollection',
							type: 'GET',
							data: {
								course_id: type,user_id:user_id
							}, //传参
							success: function(data, textStatus, jqXHR) {
								if(data.code == "2"){
									$('#icon-star').removeClass("mui-icon-star").addClass("mui-icon-star-filled");//样式
									alert(data.msg);
								}else{
									alert(data.msg);
								}
								
							}
						});
	            	} else{
	            		//$(this).removeClass("mui-icon-star-filled").addClass("mui-icon-star");//样式
	            		mui.ajax({ //ajax请求
							url: getServerIp + 'AppCourse/delCollection',
							type: 'GET',
							data: {
								course_id: type,user_id:user_id
							}, //传参
							success: function(data, textStatus, jqXHR) {
									$('#icon-star').removeClass("mui-icon-star-filled").addClass("mui-icon-star");//样式
									alert("取消收藏");
							}
						});
	            	}
            	} else{
            		mui.openWindow({
                        url: '../../login.html', 
                        id:'login'
                    });
            	}
            }); 
        });
 
		</script>
		<link rel="stylesheet" href="../../css/mui.min.css">
		<style>
			html,
			body {
				background-color: #efeff4; 
			}
			.mui-bar-nav~.mui-content {
				padding: 0;
			}
			.title {
				margin: 20px 15px 10px;
				color: #6d6d72;
				font-size: 15px;
			}
			
			.mui-title input {
				width: 75%;
				height: 28px;
                border-radius: 5px;
                background: #CAFFE0;
                border: 1px solid #DDDDDD;
                font-size: 14px;
                color: #aaa;
                padding-left: 10px;
                padding-right:20px; 
                margin-left: 40px;
                background:url("images/fdj.png") no-repeat scroll right center transparent; 
			}
		</style>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<button class="mui-action-back mui-btn mui-btn-blue mui-btn-link mui-btn-nav mui-pull-left">
				<span class="mui-icon mui-icon-left-nav" style="float: left;height: 40px;line-height: 40px;"></span>
				<img src="../../images/logo.png"  style=" height: 40px;"/>
			</button>
			<h1 class="mui-title">课程详情</h1>
			<a id="icon-star" class="mui-icon mui-icon-star mui-pull-right"></a> <!-- mui-icon-star-filled 填满-->
		</header> 
	</body>
</html>